﻿<%@ WebHandler Language="C#" Class="ChangeTypeSotr" %>

using System;
using System.Web;

public class ChangeTypeSotr : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        try
        {
            string colunmID = context.Request.QueryString["ID"];    //需要改变的栏目编号
            string action = context.Request.QueryString["Action"];  //操作
            string changeID = context.Request.QueryString["CID"];   //被替代的栏目编号

            string sql = "";
            //向上
            if (action.ToLower() == "up")
            {
                sql +=
                    string.Format("UPDATE Whir_CommonCategory SET sort = sort - 1 WHERE CategoryId = {0};", colunmID);
                sql +=
                    string.Format("UPDATE Whir_CommonCategory SET sort = sort + 1 WHERE CategoryId = {0};", changeID);
            }
            else if (action.ToLower() == "down") //向下
            {
                sql +=
                    string.Format("UPDATE Whir_CommonCategory SET sort = sort + 1 WHERE CategoryId = {0};", colunmID);
                sql +=
                    string.Format("UPDATE Whir_CommonCategory SET sort = sort - 1 WHERE CategoryId = {0};", changeID);
            }

            Whir.SQLServerDAL.DbHelperSQL.ExecuteSql(sql);

            context.Response.Write("var data = true;");
        }
        catch
        {
            context.Response.Write("var data = false;");
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}